#ifndef NETSYNCH_H
#define  NETSYNCH_H


//netSynch.h
// The class to keep all the locks that request to the server
#include "copyright.h"
#include "list.h"
#include <vector>
#include "system.h"
#include "network.h"
#include "post.h"
#include "interrupt.h"

using namespace std;

struct lockPacket{
  PacketHeader inPktHdr;
  MailHeader inMailHdr;

};

struct myLock{
  int lockID;
  bool lockBusy;
  int lockOwner;
  List* lp;
};

struct myCond{
  int condID;
  int lockID;
  List* waitCV;
};

class NetSynch{
 public:

  NetSynch();
  int createLock(int i);
  void destroyLock(int i);
  bool isBusy(){return true;}
  bool sendMsg(PacketHeader, MailHeader,char*);

  int Acquire(int iden,PacketHeader,MailHeader);
  void Release(int i,PacketHeader,MailHeader);
 
  /*Condition code*/
  int createCondition(int i);
  void Wait(int, int, PacketHeader, MailHeader);
  void Signal(int, int, PacketHeader);
  void Broadcast(int, int, PacketHeader);

 private:

  myCond* condArray;
  myLock* lockArray;
  
};

#endif
